//
// Ishtar C++ Utility Library
//
// Task Facility - Detail - Work Strand Reference Wrapper Header
//

#ifndef __ISHTAR_TASK_DETAIL_WORK_STRAND_REF_H
#define __ISHTAR_TASK_DETAIL_WORK_STRAND_REF_H

#include <Ishtar/Ishtar.h>

#if defined( ISHTAR_COMPILER_HAS_PRAGMA_ONCE )
#pragma once
#endif

#include <Ishtar/Exception.h>


namespace Ishtar
{

namespace Task
{

///////////////////////////////////////////////////////////////////////////////
//
// Work Strand Reference Wrapper
//

class WorkStrand;

class WorkStrandRef
{
public:

    WorkStrandRef( WorkStrand& obj )
        : m_pointer( &obj )
    {}

    WorkStrandRef( WorkStrand* ptr )
        : m_pointer( ptr )
    {
        ISHTAR_ASSERT( NULL != ptr );
    }

    template< typename SmartPtr >
    WorkStrandRef( const SmartPtr& sp )
        : m_pointer( sp.get() )
    {
        ISHTAR_ASSERT( NULL != sp.get() );
    }

    operator WorkStrand&() const { return *m_pointer; }

private:
    WorkStrand* m_pointer;
};


///////////////////////////////////////////////////////////////////////////////

} // namespace Task

} // namespace Ishtar

#endif // __ISHTAR_TASK_DETAIL_WORK_STRAND_REF_H
